package com.example.teaknower.method;

import android.os.Bundle;
import android.util.Log;

import com.example.teaknower.activity.ZhiDaoDetailsActivity;
import com.tencent.connect.share.QQShare;
import com.tencent.tauth.IUiListener;
import com.tencent.tauth.Tencent;
import com.tencent.tauth.UiError;

public class OnClickShare {
    private static final String TAG = "MainActivity";

    private String Tag = "分享";

    private ZhiDaoDetailsActivity zhiDaoDetailsActivity;
    private Tencent mTencent;
    private String url;
    public OnClickShare(ZhiDaoDetailsActivity zhiDaoDetailsActivity, Tencent mTencent, String url){
        this.zhiDaoDetailsActivity = zhiDaoDetailsActivity;
        this.mTencent = mTencent;
        this.url = url;
    }

    public void share() {
        final Bundle params = new Bundle();
        params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_DEFAULT);
        params.putString(QQShare.SHARE_TO_QQ_TITLE, "我在茶知道看到了一种好茶，一起来看看吧");
        params.putString(QQShare.SHARE_TO_QQ_TARGET_URL,  url);
        params.putString(QQShare.SHARE_TO_QQ_IMAGE_URL,"http://wx4.sinaimg.cn/orj360/006EaUfLly1fgiqfri2xsj30a20a0q2y.jpg");
        params.putString(QQShare.SHARE_TO_QQ_APP_NAME,  "茶知道");
        mTencent.shareToQQ(zhiDaoDetailsActivity, params, new ShareUiListener());

    }

    private class ShareUiListener implements IUiListener {

        @Override
        public void onComplete(Object response) {
            Log.i(Tag,"13");
            //分享成功
        }

        @Override
        public void onError(UiError uiError) {
            Log.i(Tag,"失败");
            //分享失败
        }

        @Override
        public void onCancel() {
            Log.i(Tag,"取消分享");
            //分享取消
        }
    }
}
